﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using MN.Model;
namespace MN.BLL
{
    public class Notice
    {
        //建立数据访问层实例 
        private MN.DAL.Notice dal = new MN.DAL.Notice();
        /// <summary> 
        /// 插入的方法 
        /// <param name="notice">数据实例</param> 
        /// </summary> 
        public void Insert(NoticeModel notice) { dal.Insert(notice); }
        /// <summary> 
        /// 更新的方法 
        /// <param name="notice">数据实例</param> 
        /// </summary> 
        public void Update(NoticeModel notice) { dal.Update(notice); }
        /// <summary> 
        /// 删除的方法 
        /// <param name="vals">实例ID，多个实例的ID以逗号（“,”）分隔</param> 
        /// </summary> 
        public void Delete(string vals)
        {
            if (!String.IsNullOrEmpty(vals))
            {
                string[] arrVals = vals.Split(new char[] { ',' });
                foreach (string val in arrVals)
                {
                    if (!Regex.IsMatch(val.Trim(), @"^\d+$")) continue;
                    dal.Delete(Convert.ToInt32(val.Trim()));
                }
            }
        }
        /// <summary> 
        /// 获取单个实例的方法 
        /// <param name="pkid">实例ID</param> 
        /// </summary> 
        public NoticeModel GetModel(string pkid)
        {
            if (String.IsNullOrEmpty(pkid) || !Regex.IsMatch(pkid, @"^\d+$")) return null; return dal.GetModel(Convert.ToInt32(pkid));
        }
        /// <summary> 
        /// 获取实例列表的方法 
        /// <param name="pageIndex">页索引</param> 
        /// <param name="pageSize">每页显示的记录数</param>  
        /// <param name="strWhere">查询条件SQL语句</param>  
        /// </summary>  
        public List<NoticeModel> GetList(int pageIndex, int pageSize, string strWhere)
        {
            return dal.GetList(pageIndex, pageSize, strWhere);
        }
    }
}

